<?php
defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );
class Session_model extends CI_model {
	public function __construct($database = 'default') {
		parent::__construct ();
		$this->db = $this->load->database ( $database, TRUE );
		$this->table = 'sys_sessions';
	}
	/**
	 * 创建数据表
	 */
	public function create() {
		$this->drop ();
		$sql = "CREATE TABLE `sys_sessions` (
					  `id` varchar(40) NOT NULL,
					  `ip_address` varchar(45) NOT NULL,
					  `timestamp` int(10) unsigned NOT NULL DEFAULT '0',
					  `data` blob NOT NULL,
					  PRIMARY KEY (`id`),
					  KEY `ci_sessions_timestamp` (`timestamp`)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='系统：session存取';";
		$re = $this->db->simple_query ( $sql );
		return $re;
	}
	/**
	 * 删除数据表
	 */
	public function drop() {
		$sql = 'DROP TABLE IF EXISTS `sys_sessions`;';
		$re = $this->db->simple_query ( $sql );
		return $re;
	}
}